
#include "stdafx.h"
#include <cstring>
#include <iostream>
#include "dma.h"

baseDMA::baseDMA(const char* l,int r)
{
	lable = new char[std::strlen(l) + 1];
	std::strcpy(lable,l);
	rating = r;
}
baseDMA::baseDMA(const baseDMA & rs)
{
	lable = new char[ std::strlen(rs.lable)+ 1];
	std::strcpy(lable,rs.lable);
	rating = rs.rating;
}
baseDMA::~baseDMA()
{
	delete []lable;	
}
baseDMA & baseDMA::operator=(const baseDMA & rs)
{
	if(this == &rs)
		return *this;
	delete [] lable;
	lable = new char[std::strlen(rs.lable)+ 1];
	std::strcpy(lable,rs.lable);
	rating = rs.rating;
	return *this;
}
std::ostream & operator<<(std::ostream &os,const baseDMA &rs)
{
	os << "Lable:" << rs.lable << std::endl;
	os << "Rating:" << rs.rating << std::endl;
	return os;
}

//lacksDMA
lacksDMA::lacksDMA(const char *c,const char *l ,int r)
	:baseDMA(l,r)
{
	strncpy(color,c,COL_LEN-1);
	color[COL_LEN]='\0';
}
lacksDMA::lacksDMA(const char* c,const baseDMA &rs):
	baseDMA(rs)
{
	strncpy(color,c,COL_LEN-1);
	color[COL_LEN]='\0';
}
std::ostream & operator<<(std::ostream &os,const lacksDMA &rs)
{
	os << (const baseDMA &) rs;
	os << "Color:" << rs.color << std::endl;
	return os;
};

//hasDMA
hasDMA::hasDMA(const char *s,const char *l,int r)
	:baseDMA(l,r)
{
	style = new char[strlen(s) + 1];
	strcpy(style,s);
}
hasDMA::hasDMA(const baseDMA &rs,const char *s)
	:baseDMA(rs)
{
	style = new char[strlen(s) + 1];
	strcpy(style,s);
}
hasDMA::hasDMA(const hasDMA &hs)
	:baseDMA(hs)
{
	style = new char[strlen(hs.style) + 1];
	strcpy(style,hs.style);
}
hasDMA::~hasDMA()
{
	delete [] style;
}
hasDMA & hasDMA::operator=(const hasDMA &h)
{
	if(this == &h)
		return *this;
	baseDMA::operator=(h);
	style = new char[strlen(h.style) + 1];
	strcpy(style,h.style);
	return *this;
}
std::ostream &operator <<(std::ostream &os,const hasDMA &hs)
{
	os << (const baseDMA &)hs;
	os <<"Style:" << hs.style << std::endl;
	return os;
}
